<?php
namespace app\Admin\controller\user;

//引入公共控制器
use app\common\controller\Backend;



class Personnel extends Backend
{
    

    public function __construct(){

        //继承父类
        parent::__construct();
        //创建公共的属性
        $this->ProductModel = model('Product.Product');
        $this->TypeModel = model('Product.Type');

        $this->VipModel = model('Product.Vip');

        $this->AdminModel = model('Admin');
    }

    
   

    
   
    
    public function index(){ 
        $count = $this->VipModel->count();

        $countlist = $this->VipModel->order('level', 'desc')->paginate(10);

        // $countlist = $this->ProductModel->alias('p')->join('type t','t.id=p.typeid')->paginate(10);
        // echo $this->ProductModel->getlastSql();
        //     exit;

        $pagestr = $countlist->render();

        // var_dump($countlist);
        // exit;

        $this->assign([
            'count' => $count,
            'countlist' => $countlist,
            'pagestr' => $pagestr
        ]);

        return $this->fetch();
    }


    public function del()
    {
        if($this->request->isPost()){

            $success = [
                'result' => false,
                'msg' => ''
            ];

            $ids = $this->request->param('ids', 0);

            $result = $this->VipModel->destroy($ids);


            if($result === FALSE)
            {
                $success['result'] = false;
                $success['msg'] = $this->VipModel->getError();
            }else
            {
                $success['result'] = true;
                $success['msg'] = '删除配置成功';
            }

            return json($success);
        }
    }

}
